package com.system.service.impl;

import com.system.mapper.VendorMapper;
import com.system.pojo.Vendor;
import com.system.service.VendorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("VendorService")
public class VendorServiceImpl implements VendorService {

    @Autowired

    VendorMapper vendorMapper;

    @Override
    public List<Vendor> selectVendor(Vendor vendor) {
        return vendorMapper.selectVendor();
    }

    @Override
    public List<Vendor> selectVendorByPage(Vendor vendor, int page, int limit) {
        int starRow = (page - 1) * limit + 1;
        int endRow = page * limit;
        String vendorCode = vendor.getVendorCode();
        return vendorMapper.selectVendorByPage(vendorCode, starRow, endRow);
    }

    @Override
    public void delVendor(String id) {
        try {
            vendorMapper.delVendor(id);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void insertVendor(Vendor vendor) {
        vendorMapper.insertVendor(vendor);
    }

    @Override
    public void updateVendor(Vendor vendor) {
        vendorMapper.updateVendor(vendor);
    }


}
